import tkinter as tk
import wx
import wx.lib.sized_controls as sc


class MyApp(wx.App):
    def OnInit(self):
        self.frame = wx.Frame(None, title="wxPython Frame")
        self.panel = wx.Panel(self.frame)
        self.text = wx.StaticText(self.panel, label="Hello from wxPython!")
        self.frame.Show()
        return True


def create_wx_frame(root):
    add_widgets(root)
    app = MyApp(False)  # 创建但不启动GUI主循环
    # app.MainLoop()#创建主循环之后就不会再执行下面的代码
    frame = app.frame
    # 创建一个Tkinter Canvas，并将wxPython Frame嵌入其中
    canvas = tk.Canvas(root, width=300, height=200)
    canvas.pack()
    # 两个不同的框架,没法嵌入,
    # canvas_id = canvas.create_window(100, 200, window=frame, anchor='nw')
    return canvas, frame, app

def add_widgets(tk_root):
    label = tk.Label(tk_root, text="这是一个Tkinter标签")  # 创建标签
    label.pack(pady=10)  # 将标签添加到窗口并设置边距

    button = tk.Button(tk_root, text="打开wx窗口")  # 创建按钮
    button.pack(pady=10)  # 将按钮添加到窗口并设置边距

root = tk.Tk()
root.geometry("780x640")
canvas, frame, app = create_wx_frame(root)

# add_widgets(root)
root.mainloop()